package com.lcxw.hxzbapi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lcxw.hxzbapi.dao.mapper.PhotoMapper;
import com.lcxw.hxzbapi.entity.pojo.Photo;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class PhotoService {

    @Resource
    PhotoMapper photoMapper;

    public int insert(Photo photo) {
        return photoMapper.insert(photo);
    }

    public Photo selectById(int id) {
        return photoMapper.selectById(id);
    }

    public List<Photo> selectByUserId(long userId) {
        QueryWrapper<Photo> photoQueryWrapper = new QueryWrapper<>();
        photoQueryWrapper.eq("userId", userId);
        return photoMapper.selectList(photoQueryWrapper);
    }

    public int deleteById(int id) {
        return photoMapper.deleteById(id);
    }

    public int selectCountByUserId(long userId) {
        QueryWrapper<Photo> photoQueryWrapper = new QueryWrapper<Photo>();
        photoQueryWrapper.eq("userId", userId);
        return photoMapper.selectCount(photoQueryWrapper);
    }

}
